package com.zwj.rms.controller;


import com.zwj.rms.bo.RoleBo;
import com.zwj.rms.entity.SysRoleEntity;
import com.zwj.rms.service.SysRoleService;
import com.zwj.rms.utils.TokenUtils;
import com.zwj.rms.vo.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 角色表 前端控制器
 * </p>
 *
 * @author zwj
 * @since 2021-09-13
 */
@RestController
@RequestMapping("/role")
public class SysRoleController {
    private final SysRoleService sysRoleService;

    public SysRoleController(SysRoleService sysRoleService) {
        this.sysRoleService = sysRoleService;
    }

    @ApiOperation(value = "条件查询角色", notes = "条件查询角色")
    @PostMapping("/selectRole")
    public Result selectRole(@RequestBody RoleBo roleBo) {
        return sysRoleService.selectRole(roleBo);
    }
    @ApiOperation(value = "修改角色状态", notes = "修改角色状态")
    @PostMapping("/updateRoleStatus")
    public Result updateRoleStatus(@RequestBody RoleBo roleBo) {
        return sysRoleService.updateRoleStatus(roleBo);
    }
    @ApiOperation(value = "删除角色", notes = "删除角色")
    @PostMapping("/deleteRole")
    public Result deleteRole(@RequestBody RoleBo roleBo) {
        return sysRoleService.deleteRole(roleBo);
    }
    @ApiOperation(value = "添加角色", notes = "添加角色")
    @PostMapping("/addRole")
    public Result addRole(@RequestBody SysRoleEntity sysRoleEntity) {
        return sysRoleService.addRole(sysRoleEntity);
    }
    @ApiOperation(value = "修改角色信息", notes = "修改角色信息")
    @PostMapping("/updateRole")
    public Result updateRole(@RequestBody SysRoleEntity sysRoleEntity) {
        return sysRoleService.updateRole(sysRoleEntity);
    }
    @ApiOperation(value = "查询角色菜单信息", notes = "查询角色菜单信息")
    @PostMapping("/selectRoleMenu")
    public Result selectRoleMenu(@RequestBody RoleBo roleBo) {
        return sysRoleService.selectRoleMenu(roleBo);
    }
    @ApiOperation(value = "修改角色信息", notes = "修改角色信息")
    @PostMapping("/updateRoleMenu")
    public Result updateRoleMenu(@RequestBody RoleBo roleBo) {
        return sysRoleService.updateRoleMenu(roleBo);
    }

    @ApiOperation(value = "查询角色用户信息", notes = "查询角色用户信息")
    @PostMapping("/selectUserRole")
    public Result selectUserRole(@RequestBody RoleBo roleBo) {
        return sysRoleService.selectUserRole(roleBo);
    }
    @ApiOperation(value = "修改角色信息", notes = "修改角色信息")
    @PostMapping("/cancelRoleUser")
    public Result cancelRoleUser(@RequestBody RoleBo roleBo) {
        return sysRoleService.cancelRoleUser(roleBo);
    }

    @ApiOperation(value = "修改角色信息", notes = "修改角色信息")
    @PostMapping("/getMenu")
    public Result getMenu(HttpServletRequest request) {
        String userID = TokenUtils.getUserID(request);
        return sysRoleService.getMenu(userID);
    }
}

